﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Obra.PowerShell.SmugMug;

namespace Obra.Test.SmugMug.PowerShell
{
    [TestFixture]
    public class PathTester
    {
        private Path path = new Path("smugmug:");

        [Test]
        public void Combine()
        {
            Assert.AreEqual(
                @"smugmug:",
                Path.Combine("smugmug:"));
                
            Assert.AreEqual(
                @"smugmug:\album",
                Path.Combine(@"smugmug:\", "album"));

            Assert.AreEqual(
                @"smugmug:\album\image.jpg",
                Path.Combine(@"smugmug:\", "album", "image.jpg"));

            Assert.AreEqual(
                @"smugmug:\album",
                Path.Combine(@"smugmug:\", "album"));
        }

        [Test]
        public void GetChildName()
        {
            Assert.AreEqual(
                @"smugmug:\",
                Path.GetChildName(@"smugmug:\"));

            Assert.AreEqual(
                "album",
                Path.GetChildName(@"smugmug:\album"));

            Assert.AreEqual(
                "album",
                Path.GetChildName(@"smugmug:\album\"));

            Assert.AreEqual(
                "image",
                Path.GetChildName(@"smugmug:\album\image"));
        }

        [Test]
        public void IsValidPath()
        {
            Assert.IsFalse(Path.IsValidPath(null));
            Assert.IsFalse(Path.IsValidPath(String.Empty));

            Assert.IsTrue(Path.IsValidPath(@"smugmug:"));
            Assert.IsTrue(Path.IsValidPath(@"smugmug:\album"));
            Assert.IsTrue(Path.IsValidPath(@"smugmug:\album\image.jpg"));

            Assert.IsFalse(Path.IsValidPath(@"smugmug:\"));
        }

        [Test]
        public void Normalize()
        {
            Assert.AreEqual(
                "smugmug:", 
                Path.Normalize("smugmug:"));
            
            Assert.AreEqual(
                @"smugmug:\album\image.jpg",
                Path.Normalize(@"smugmug:\album\image.jpg"));

            Assert.AreEqual(
                @"smugmug:\album\image.jpg",
                Path.Normalize("smugmug:/album/image.jpg"));
        }
    }
}
